package org.daochong.lang;

import java.io.File;
import java.util.List;

import javax.tools.JavaCompiler;
import javax.tools.ToolProvider;

@SuppressWarnings("all")
public class JavaTools {
	public static void main(String[] args) {
		System.out.println(javax.sql.DataSource.class.getProtectionDomain().getCodeSource());
	}

	public static void compiler(String javaFile, String outPath, String... args) {
		compiler(new File(javaFile), outPath, null, args);

	}

	public static void compiler(String javaFile, String outPath, List<String> classPath, String... args) {
		compiler(new File(javaFile), outPath, null, args);
	}

	public static void compiler(File javaFile, String outPath, String... args) {
		compiler(javaFile, outPath, null, args);
	}

	public static void compiler(File javaFile, String outPath, List<String> classPath, String... args) {
		JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
		compiler.run(null, System.out, System.err, "-d",outPath,"-cp",classPath.toString().replaceAll(",", ";"),javaFile.getPath());
	}
}
